package cn.etcweb.bait.baitframe.system.web;

import cn.etcweb.bait.baitframe.system.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/user/")
@Api(value = "Swagger2测试",description = "Swagger2测试")
public class UserController {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Autowired
    private UserService userService;

    @RequestMapping(value = "getUser", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取用户信息",notes = "获取用户信息" )
    public String getUser(){
        //stringRedisTemplate.opsForValue().set("bait","123456");
        //System.out.println("获取结果:"+stringRedisTemplate.opsForValue().get("bait"));
        return userService.getUser();
    }

    @RequestMapping(value = "addUser")
    @ResponseBody
    @ApiOperation(value = "添加用户信息",notes = "添加用户信息",httpMethod = "POST")
    public String addUser(@RequestParam(required = true) String name,@RequestParam(required = true)  String pass){
        userService.addUser(name,pass);
        return "操作成功";
    }
}
